import javax.imageio.IIOException;
import java.io.File;
import java.io.IOException;
import java.util.function.DoubleToIntFunction;

public class Main {
    public static void main(String[] args) {
        File f =new File("test.txt");
        if (f.exists()){
            System.out.println("文件存在");
        }else{
            System.out.println("文件不存在");
            try{
                f.createNewFile();
            }catch(IOException e){
                System.out.println("创建文件异常。");
                e.printStackTrace();
            }

            System.out.println(f.canRead());
            System.out.println(f.canWrite());
        }
        File f2 = new File("src","Main.java");
        System.out.println("文件的路径：" + f2.getAbsolutePath());
        if(f2.exists()){
            System.out.println("Main.java文件存在");
            System.out.println(f2.canRead());
            System.out.println(f2.canWrite());
            System.out.println(f2.canExecute());
            System.out.println(f2.getName());
            System.out.println(f2.getParent());
            System.out.println(f2.getPath());
            System.out.println(f2.length());
        }else{
            System.out.println("Main.java文件不存在");
        }
        File f3 = new File("DIR");
        if(f3.mkdir()){
            System.out.println("目录创建成功。");
        }else{
            System.out.println("目录创建不成功。");
        }
        String[] filenames = f3.list();
        if (null != filenames){
            for (String item: filenames){
                System.out.println(item);
            }
        }
        System.out.println("------------------------------");
        FileFilter filter = new FileFilter();
        String[] filteredFileNames = f3.list(filter);
        if(filteredFileNames !=null){
            for(String item : filteredFileNames){
                System.out.println(item);
            }
        }
    }
}